package org.example.objectFactory;

import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class SingletonBean {
    private final ObjectFactory<PrototypeBean> prototypeBeanFactory;

    @Autowired
    public SingletonBean(ObjectFactory<PrototypeBean> prototypeBeanFactory) {
        this.prototypeBeanFactory = prototypeBeanFactory;
    }

    public void doSomething() {
        PrototypeBean prototypeBean = prototypeBeanFactory.getObject();
        // 使用prototypeBean
    }
}
